// mallPages/user/user.js
Page({

  /**
   * 页面的初始数据
   */
  data: {
    // 订单状态列表
    chooseList: [{
      id: 0,
      onthis: true,
      name: "待发货"
    }, {
      id: 1,
      onthis: false,
      name: "待收货"
    }, {
      id: 2,
      onthis: false,
      name: "已完成"
    }],
    // 订单列表
    orderList: [{
      number: "2020050729098736278",
      name: "月饼礼盒",
      user: "王多鱼",
      phone: "15212348570",
      address: "上海市浦东新区XXX"
    }, {
      number: "2020050729098736278",
      name: "月饼礼盒",
      user: "王多鱼",
      phone: "15212348570",
      address: "上海市浦东新区XXX"
    }, {
      number: "2020050729098736278",
      name: "月饼礼盒",
      user: "王多鱼",
      phone: "15212348570",
      address: "上海市浦东新区XXX"
    }]
  },

  // 订单状态选择事件
  listChoose: function (e) {
    let id = e.currentTarget.id, list = this.data.chooseList;
    for (let i = 0; i < list.length; i++) {
      if (list[i].id == id) {
        list[i].onthis = true
      } else {
        list[i].onthis = false
      }
    }
    this.setData({
      chooseList: list
    })
  }
})